//
//  WLBaseCollectionViewLayerModel.m
//  xiacai_ios_v6
//
//  Created by shushui on 2018/4/18.
//  Copyright © 2018年 王振标. All rights reserved.
//

#import "WLBaseCollectionViewLayerModel.h"

@implementation WLBaseCollectionViewLayerModel
-(NSMutableArray<WLBaseCollectionViewLayerSection *> *)viewLayer{
    if (!_viewLayer){
        _viewLayer = [NSMutableArray array];
    }
    return _viewLayer;
}

-(id)getCellData:(NSIndexPath *)indexPath{
    return [[[self.viewLayer objectAtIndex:indexPath.section].item objectAtIndex:indexPath.row] data];
}
-(WLBaseCollectionViewLayerRow *)getCellModel:(NSIndexPath *)indexPath{
    return [[self.viewLayer objectAtIndex:indexPath.section].item objectAtIndex:indexPath.row];
}

-(WLBaseCollectionViewLayerSection *)getSectionModel:(NSIndexPath *)indexPath{
    return [self.viewLayer objectAtIndex:indexPath.section];
}
@end
@implementation WLBaseCollectionViewLayerSection
-(NSMutableArray<WLBaseCollectionViewLayerRow *> *)item{
    if (!_item){
        _item = [NSMutableArray array];
    }
    return _item;
}
-(CGFloat)getCellWidth{
    NSInteger count = self.horizontalCount;
    CGFloat maxWidth = self.horizontalMaxWidth ? self.horizontalMaxWidth : Main_Screen_Width;
    CGFloat w = (maxWidth - self.insetForSection.left - self.insetForSection.right - (self.verticalSection * (count - 1)))/count;
    return w;
}
-(CGSize)getCellSizeHeight:(CGFloat)height{
    CGFloat w = [self getCellWidth];
    CGFloat h = height;
    return CGSizeMake(w, h);
}

@end
@implementation WLBaseCollectionViewLayerRow
-(NSString *)keyId{
    if (!_keyId){
        if (self.viewClass){
            _keyId = NSStringFromClass(self.viewClass);
        } else if (self.nibClass){
            _keyId = NSStringFromClass(self.viewClass);
        } else {
            _keyId = @"cellName";
        }
    }
    return _keyId;
}
@end
